package com.example.mapper;

import com.example.entity.Equipment;
import com.example.entity.Event;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface EquipmentMapper {

    //器材分页查询
    @Select("select * from equipment ")
    List<Equipment> queryEquipment();

    //器材查询
    @Select("select * from equipment where equipmentId = #{equipmentId}")
    List<Equipment> selectEquipment(@Param("equipmentId") String equipmentId);

    //器材购置新增
    @Insert("insert into equipment(equipmentName, equipmentState, equipmentCharges) values(#{equipmentName}, #{equipmentState}, #{equipmentCharges})")
    void addEquipment(@Param("equipmentName") String equipmentName, @Param("equipmentState") String equipmentState, @Param("equipmentCharges") String equipmentCharges);

    //器材报废删除
    @Delete("delete from equipment where equipmentId = #{equipmentId}")
    void deleteEquipment(@Param("equipmentId") int equipmentId);

    //器材维护报修
    @Update("update equipment set equipmentState = #{equipmentState} where equipmentId = #{equipmentId}")
    int repairEquipment(@Param("equipmentId") String equipmentId);

    //器材租用
    @Update("update equipment set equipmentState = #{equipmentState} where equipmentId = #{equipmentId}")
    int rentEquipment(@Param("equipmentId") String equipmentId);

    //器材回收
    @Update("update equipment set equipmentState = #{equipmentState} where equipmentId = #{equipmentId}")
    int recoveryEquipment(@Param("equipmentId") String equipmentId);

    //器材租用收费标准查询
    @Select("select equipmentCharges,equipmentName from equipment where equipmentId = #{equipmentId}")
    List<Equipment> chargeEquipment(@Param("equipmentId") String equipmentId);

    @Select("select * from equipment order by startTime desc limit 10")
    List<Equipment> selectTime();

}
